/*
 * SymbolTable.h
 *
 *  Created on: Nov 23, 2010
 *      Author: dhovemey
 */

#ifndef SYMBOLTABLE_H_
#define SYMBOLTABLE_H_

#include <map>
#include <string>

class ASTNode;

class SymbolTableEntry {
public:
	enum Kind {
		PARAM,
		LOCAL_VAR,
		FIELD,
		METHOD,
		MODULE,
	};

private:
	std::wstring m_name;
	Kind m_kind;

	SymbolTableEntry(const SymbolTableEntry &);
	SymbolTableEntry& operator=(const SymbolTableEntry &);

public:
	SymbolTableEntry(const std::wstring &name, Kind kind);
	virtual ~SymbolTableEntry();

	const std::wstring &getName() const { return m_name; }
	Kind getKind() const { return m_kind; }
};

class SymbolTable {
private:
	typedef std::map<std::wstring, SymbolTableEntry *> Environment;

	SymbolTable *m_parent;
	Environment m_env;

	SymbolTable(const SymbolTable &other);
	SymbolTable& operator=(const SymbolTable &);

public:
	SymbolTable(SymbolTable *parent);
	virtual ~SymbolTable();

	SymbolTableEntry *addMember(ASTNode *member);
};

#endif /* SYMBOLTABLE_H_ */
